package org.mock.controller;

import lombok.AllArgsConstructor;
import org.mock.common.R;
import org.mock.utils.Func;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
import org.mock.entity.BaifenhuiOrderProduct;
import org.mock.dto.BaifenhuiOrderProductDTO;

import org.mock.service.BaifenhuiOrderProductService;

/**
 * 订单商品信息
 *
 * @author AI
 * @since 2025-05-23
 */
@RestController
@AllArgsConstructor
@RequestMapping("baifenhuiOrderProduct")
public class BaifenhuiOrderProductController {

	private BaifenhuiOrderProductService baifenhuiOrderProductService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	public R<BaifenhuiOrderProduct> detail(BaifenhuiOrderProductDTO dto) {
		BaifenhuiOrderProduct detail = baifenhuiOrderProductService.getOne(dto);
		return R.data(detail);
	}

	/**
	 * 分页 订单商品信息
	 */
	@GetMapping("/page")
	public R<IPage<BaifenhuiOrderProduct>> page(BaifenhuiOrderProductDTO dto) {
		IPage<BaifenhuiOrderProduct> pages = baifenhuiOrderProductService.page(dto);
		return R.data(pages);
	}
	/**
	 * 不分页 订单商品信息
	 */
	@GetMapping("/list")
	public R<List<BaifenhuiOrderProduct>> list(BaifenhuiOrderProductDTO dto) {
		List<BaifenhuiOrderProduct> list = baifenhuiOrderProductService.list(dto);
		return R.data(list);
	}

	/**
	 * 新增 订单商品信息
	 */
	@PostMapping("/save")
	public R save(@RequestBody BaifenhuiOrderProductDTO dto) {
		return R.data(baifenhuiOrderProductService.save(dto));
	}

	/**
	 * 修改 订单商品信息
	 */
	@PutMapping("/update")
	public R update(@RequestBody BaifenhuiOrderProductDTO dto) {
		return R.data(baifenhuiOrderProductService.updateById(dto));
	}

	/**
	 * 删除 订单商品信息
	 */
	@DeleteMapping("/remove")
	public R remove(@RequestParam String ids) {
		return R.data(baifenhuiOrderProductService.deleteLogic(Func.toIntList(ids)));
	}

}
